#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N;
typedef pair<int, int> cost;
typedef long long ll;
vector<cost> vs;

void solve();
int main() {
    cin >> N;
    int t, d;
    for (int i = 0; i < N; i++) {
        cin >> t >> d;
        vs.push_back({t, d});
    }
    solve();
}

bool cmp(const cost & c1, const cost & c2) {
    return c1.second * c2.first > c2.second * c1.first;
}

void solve() {
    sort(vs.begin(), vs.end(), cmp);
    ll res = 0, t = vs[0].first * 2;
    for (int i = 1; i < N; i++) {
        res += t * vs[i].second;
        t += vs[i].first * 2;
    }
    cout << res << endl;
}